home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / C++ A'Link Files / 1989 / 0025-learning c++-Dec89 < prev    next >
Encoding:
Text File  |  1991-03-06  |  1.5 KB  |  63 lines  |  [TEXT/GEOL]

  1. Item    5035151                         19-Dec-89        17:55
  2.  
  3. From:   ALCABES                         Alcabes, Harvey
  4.  
  5. To:     CP.ARCHIVES                     C++ Archives
  6.  
  7. Sub:    learning c++
  8.  
  9. Item    8456638                         17-Nov-89        05:34
  10.  
  11. From:   D2078                           AS & M, Alan Dail,PRT
  12.  
  13. To:     CPLUS.DEV$                      C++ Interest List--Developers
  14.         CPLUS.ADMIN                     C++ Group Addresses Administrator
  15.  
  16. Sub:    learning c++
  17.  
  18. I'm trying to learn c++ and have a question?
  19.  
  20. i am currently doing something like the following:
  21.  
  22. HandleObject*& newRef (HandleObject*& h) {
  23.     cout << "reassign reference " << h << '\n';
  24.     return h;
  25. }
  26.  
  27. HandleObject*& addRef (HandleObject*& h) {
  28.     cout << "new reference " << h << '\n';
  29.     return h;
  30. }
  31.  
  32. void delRef (HandleObject*& h) {
  33.     cout << "delete reference " << h << '\n';
  34.     return h;
  35. }
  36.  
  37. main () {
  38.     HandleObject* h = addRef (new HandleObject);
  39.     newRef (h) = addRef (h);
  40.     delRef (h);
  41. }
  42.  
  43. to trace assignements, but would much rather not have to explicitly call
  44. addRef, newRef & delRef.  is there a way to set it up so that using =
  45. automaticaly will do something like
  46. operator = (HandleObject* & a, HandleObject* & b) {
  47.     ::operator = (newRef (a), delRef (b));
  48. };
  49.  
  50. and to have delRef automatically called at the end of a function.  I need this
  51. to be done for all HandleObject* (and descendants).
  52.  
  53. any help would be greatly appreciated.
  54.  
  55. also, i tried to sent this to cplus.apple$, but got an error (address not
  56. found).
  57.  
  58. thanks
  59.  
  60. alan dail
  61.  
  62.  
  63.